﻿using System;
using System.Collections.Generic;
using System.Linq;
using ExpenseSystem.Common;
using ExpenseSystem.Fether;
using ExpenseSystem.Model;
using ExpenseSystem.Lor;

namespace ExpenseSystem.Fether
{
    public class ServiceBonusFetcher : NormalFetcher<ServiceBonusModel>,IDetailFetcher<ServiceBonusModel>
    {
        public ServiceBonusModel GetByCode( long site, string code, out string message)
        {
            IList<ServiceBonusModel> result = List( site, OrderBy.GetDefault(), Limit.GetDefault(), out message, out  rows, Restrain.Eq("Code", code));
            if (result.Count > 0)
                return result.First();
            return null;
        }
        public IList<ServiceBonusModel> ListByCustomService( long site, long employee, out string message, out int rows)
        {
            IList<ServiceBonusModel> result = List( site, OrderBy.GetDefault(), Limit.GetDefault(), out message, out rows, Restrain.Eq("CustomServiceId", employee));
            return result;
        }
        public IList<ServiceBonusModel> ListByOrder(long site, long order, out string message, out int rows)
        {
            IList<ServiceBonusModel> result = List(site, OrderBy.GetDefault(), Limit.GetDefault(), out message, out rows, Restrain.Eq("OrderId", order));
            return result;
        }
        public IList<ServiceBonusModel> ListByServiceOrderId(long site, long serviceOrderId, out string message, out int rows)
        {
            IList<ServiceBonusModel> result = List(site, OrderBy.GetDefault(), Limit.GetDefault(), out message, out rows, Restrain.Eq("ServiceOrderId", serviceOrderId));
            return result;
        }
        public IList<ServiceBonusModel> ListByMainId( long site, long mainId, out string message, out int rows)
        {
            IList<ServiceBonusModel> result = List( site, OrderBy.GetDefault(), Limit.GetDefault(), out message, out rows, Restrain.Eq("CustomerId", mainId));
            return result;
        }
    }
}
